﻿using System;
using MyUtils.PInvoke.Structs;

namespace MyUtils.PInvoke
{
	public static class GlassWindow
	{
		[Obsolete("Use Glass", true)]
		public static bool MakeGlassWindow(this IntPtr handle)
		{
			return Glass(handle);
		}

		public static bool Glass(this IntPtr handle, bool enabled = true)
		{
			if (PInvoke.GlassEnabled)
			{
				Extend(handle, enabled);
				return true;
			}
			return false;
		}

		internal static void Extend(IntPtr hwnd, bool enabled)
		{
			var margins = new MARGINS(enabled ? -1 : 0);
			PInvoke.DwmExtendFrameIntoClientArea(hwnd, ref margins);
		}

		public static bool GlassEnabled
		{
			get { return PInvoke.GlassEnabled; }
		}
	}
}
